package ${cfg.parent}.rest;


import ${cfg.parent}.bean.*;
import ${cfg.parent}.dto.*;
import ${cfg.parent}.service.*;
import com.xc.core.bean.*;
import com.xc.core.dto.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * ${cfg.describe}前端控制器
 * </p>
 *
 * @author ${author}
 * @version 1.0.0
 * @jdk 1.8.0
 * @since ${date}
 */
@RestController
@RequestMapping("/${cfg.name}")
<#--@Api(tags = "${cfg.describe}前端控制器")-->
public class ${cfg.name?cap_first}Rest {

    @Autowired
    private ${cfg.name?cap_first}Service ${cfg.name}Service;


<#--    @ApiOperation("添加")-->
    /**
     * 添加
     */
    @PostMapping
    public ${cfg.name?cap_first}Dto create${cfg.name}(@RequestBody ${cfg.name?cap_first}Bean ${cfg.name}Bean) {
        return ${cfg.name}Service.create${cfg.name}(${cfg.name}Bean);
    }


<#--    @ApiOperation("查询所有数据")-->
    /**
     * 查询所有数据
     */
    @GetMapping
    public List<${cfg.name?cap_first}Dto> get${cfg.name}(@ModelAttribute QueryBean queryBean, @ModelAttribute ${cfg.name?cap_first}Bean ${cfg.name}Bean) {
        return ${cfg.name}Service.get${cfg.name}(queryBean, ${cfg.name}Bean);
    }


<#--    @ApiOperation("分页查询")-->
<#--    @ApiParam(name = "size", value = "每页数据数量!", required = true)-->
<#--    @ApiParam(name = "id", value = "第几页!", required = true)-->
    /**
     * 分页查询
     */
    @GetMapping("/{size}/{page}")
    public PagingDto get${cfg.name}Paging(@PathVariable("size") Integer size, @PathVariable("page") Integer page,
                                          @ModelAttribute QueryBean queryBean, @ModelAttribute ${cfg.name?cap_first}Bean ${cfg.name}Bean) {
        return ${cfg.name}Service.get${cfg.name}Paging(new PagingBean(size, page), queryBean, ${cfg.name}Bean);
    }


<#--    @ApiOperation("根据id查询")-->
<#--    @ApiParam(name = "id", value = "主键id,不能为空!", required = true)-->
    /**
     * 根据id查询
     */
    @GetMapping("/{id}")
    public ${cfg.name?cap_first}Dto get${cfg.name}ById(@PathVariable("id") String id) {
        return ${cfg.name}Service.get${cfg.name}ById(id);
    }



<#--    @ApiOperation("根据id修改")-->
<#--    @ApiParam(name = "id", value = "主键id,不能为空!", required = true)-->
    /**
     * 根据id修改
     */
    @PutMapping(value = "/{id}")
    public ${cfg.name?cap_first}Dto update${cfg.name}(@PathVariable("id") String id, @RequestBody ${cfg.name?cap_first}Bean ${cfg.name}Bean) {
        return ${cfg.name}Service.update${cfg.name}(id, ${cfg.name}Bean);
    }



<#--    @ApiOperation("根据id修改")-->
<#--    @ApiParam(name = "id", value = "主键id,不能为空!", required = true)-->
    /**
     * 根据id修改
     */
    @DeleteMapping(value = "/{id}")
    public void delete${cfg.name}(@PathVariable("id") String id) {
        ${cfg.name}Service.delete${cfg.name}(id);
    }
}
